﻿using AuSys.Database.Context;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;

namespace AuSys.Test.TestSupport.Fakes
{
    public class FakeDataContext(
        SqliteConnection sqliteConnection)
        : DataContext(new() { Type = dbType })
    {
        private const string dbType = "sqlitememory";
        public override string AcceptDbType => dbType;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //应该传入一个Open的SqliteConnection（而不是文件路径）否则会造成EnsureCreated失败
            optionsBuilder.UseSqlite(sqliteConnection);
        }
        
        public DbSet<FakeEntity> FakeEntities { get; set; }
    }
}
